home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Misc / FaceFromPICT.c next >
Text File  |  1995-05-01  |  1KB  |  46 lines

  1. // C translation by Adam Wight
  2.  
  3. #include "SAT.h"
  4.  
  5. FacePtr GetFaceFromPICT (int colorPICTid,int bwPICTid,int maskPICTid);
  6.  
  7. /*No error checking yet!*/
  8.  
  9. FacePtr GetFaceFromPICT (int colorPICTid,int bwPICTid,int maskPICTid) {
  10.         Rect bounds;
  11.         PicHandle thePICT, maskPICT;
  12.         FacePtr theFace;
  13.         SATPort savePort;
  14.  
  15.         SATGetPort(&savePort);
  16.  
  17.         /*Get PICTs*/
  18.         if (gSAT.initDepth > 1) thePICT = GetPicture(colorPICTid);
  19.         else thePICT = GetPicture(bwPICTid);
  20.  
  21.         maskPICT = GetPicture(maskPICTid);
  22.         bounds = (*thePICT)->picFrame;
  23.         OffsetRect(&bounds, -bounds.left, -bounds.top); /* Unnecessary? I think NewFace does this for us. /Ingemar */
  24.  
  25.         /*Create face*/
  26.         theFace = SATNewFace(&bounds);
  27.  
  28.         /*Draw in the face*/
  29.         SATSetPortFace(theFace);
  30.         DrawPicture(thePICT, &bounds);
  31.         SATSetPortMask(theFace);
  32.         DrawPicture(maskPICT, &bounds);
  33.         /*Tell SAT that we are done*/
  34.         SATChangedFace(theFace);
  35.  
  36.         /*Get rid of the PICTs*/
  37.         ReleaseResource((Handle)thePICT);
  38.         ReleaseResource((Handle)maskPICT);
  39.  
  40.         /*Return the face.*/
  41.  
  42.         SATSetPort(&savePort);
  43.  
  44.         return theFace;
  45. }
  46.